package sharemem

import (
	//	"server_cluster/gate/config"
	//	"server_cluster/gate/logger"
	//	"server_cluster/gate/protoc/pb"
	"server_cluster/common/tools"
)

type User struct {
	Index     int32
	Uid       int64
	Fd        int32
	Session   uint64 // gate session
	Lserver   int16  // logic server id
	Bserver   int16  // battle server id
	AliveTime int64
}

func (u *User) Meminit(index int32) {
	u.Index = index
	u.Uid = 0
	u.Fd = -1
	u.Session = 0
	u.Lserver = 0
	u.Bserver = 0
	u.AliveTime = 0
}

func (u *User) IsUse() bool {
	return u.Uid > 0
}

func (u *User) use(uid int64) {
	u.Uid = uid
}

func (u *User) isMe(uid int64) bool {
	return u.Uid == uid
}

func (u *User) getId() int64 {
	return u.Uid
}

func (u *User) sessionUpdate() {
	u.Session = tools.EnSession(u.Index, u.Uid, Myshm.Time_now)
}

func (u *User) IsSession(session uint64) bool {
	return session == u.Session
}

func (u *User) GetSession() uint64 {
	return u.Session
}
